package net.lesscoding.producer;

import net.lesscoding.common.Const;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

/**
 * @author eleven
 * @date 2023/9/7 13:30
 * @apiNote
 */
public class SimpleTextMessage {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("testGroup");
        producer.setNamesrvAddr(Const.TS_NAME_SRV_ADDR_OS1);
        producer.start();
        for (int i = 0; i < 10; i++) {

            Message message = new Message("topic", "tags", ("Hi," + i).getBytes() );
            SendResult sendResult = producer.send(message, 10000);
            System.out.println(sendResult);
        }
        producer.shutdown();
    }
}
